<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第二题</title>
</head>

<body>
    <script>
        // let arr = [6, 3, 9, 22, 16, 4, 7, 66]求该数组中大于平均值的数的个数，和小于平均值的个数。
        function getJishu() {
            let arr = [6, 3, 9, 22, 16, 4, 7, 66]
            let num = 0, ji = 0, xiao = 0
            for (let i = 0; i < arr.length; i++) {
                num += arr[i]
            }
            console.log(num / arr.length)
            for (let i = 0; i < arr.length; i++) {
                if (arr[i] > num / arr.length) {
                    ji++
                } else if (arr[i] < num / arr.length) {
                    xiao++
                }
            }
            return [ji, xiao]
        }
        let shu = getJishu()
        console.log(shu)
        // console.log(a);
    </script>
</body>

</html>